<?php
namespace modules\user;

use mytp\Model;
use mytp\Captcha;
use modules\user\model\User as UserModel;
class User extends Model{
  protected $user;
  protected $captcha;
  protected $code;
  
  public function __construct(Captcha $captcha, UserModel $user) {
    $this->captcha = $captcha;
    $this->user = $user;
  }

  // 但移动端好像不用 ??
  public function captcha() {
    $this->code = $this->captcha->create();
    return [$this->captcha->show($this->code), 200, ["Content-Type" => "image/png", "code" => $this->code]];
  }

  public function data() {
    return $this->user->get();
  }

  public function success($res) {
    return $this->user->where('token', $res['token'])->where('username', $res['username'])->where('password', $res['password'])->get();
  }
}
?>